#region Using

using System;
using System.Collections.Generic;
using System.Data;

using Gizmox.WebGUI.Forms;

#endregion

namespace TVC.Modules.Ddb
{
    public partial class frmDashboardConfig : Form
    {
        //string sErr = "";

        public frmDashboardConfig(MainForm form)
        {
            InitializeComponent();
            MainForm = form;
        }
        public frmDashboardConfig(Gizmox.WebGUI.Common.Interfaces.IContext objContext)
            : base(objContext)
        {

        }
        public MainForm MainForm
        { get; set; }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MainForm.FormPara.Rows.Count == 0)
                MainForm.FormPara.Rows.Add(MainForm.FormPara.NewRow());
            foreach (DataColumn col in MainForm.FormPara.Columns)
            {
                switch (col.ColumnName)
                {
                    case "P1":
                        MainForm.FormPara.Rows[0][col] = txtP1.Text;
                        break;
                    case "P2":
                        MainForm.FormPara.Rows[0][col] = txtP2.Text;
                        break;
                    case "P3":
                        MainForm.FormPara.Rows[0][col] = txtP3.Text;
                        break;
                    case "P4":
                        MainForm.FormPara.Rows[0][col] = txtP4.Text;
                        break;
                    case "P5":
                        MainForm.FormPara.Rows[0][col] = txtP5.Text;
                        break;
                    case "P6":
                        MainForm.FormPara.Rows[0][col] = txtP6.Text;
                        break;
                    case "P7":
                        MainForm.FormPara.Rows[0][col] = txtP7.Text;
                        break;
                    case "P8":
                        MainForm.FormPara.Rows[0][col] = txtP8.Text;
                        break;
                    case "P9":
                        MainForm.FormPara.Rows[0][col] = txtP9.Text;
                        break;
                    case "P10":
                        MainForm.FormPara.Rows[0][col] = txtP10.Text;
                        break;
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        private void frmDashboardConfig_Load(object sender, EventArgs e)
        {
            if (MainForm.FormPara.Rows.Count == 0)
                MainForm.FormPara.Rows.Add(MainForm.FormPara.NewRow());
            else
            {
                txtP1.Text = MainForm.FormPara.Rows[0]["P1"].ToString();
                txtP2.Text = MainForm.FormPara.Rows[0]["P2"].ToString();
                txtP3.Text = MainForm.FormPara.Rows[0]["P3"].ToString();
                txtP4.Text = MainForm.FormPara.Rows[0]["P4"].ToString();
                txtP5.Text = MainForm.FormPara.Rows[0]["P5"].ToString();
                txtP6.Text = MainForm.FormPara.Rows[0]["P6"].ToString();
                txtP7.Text = MainForm.FormPara.Rows[0]["P7"].ToString();
                txtP8.Text = MainForm.FormPara.Rows[0]["P8"].ToString();
                txtP9.Text = MainForm.FormPara.Rows[0]["P9"].ToString();
                txtP10.Text = MainForm.FormPara.Rows[0]["P10"].ToString();
            }



        }
    }
}